import type { FormInstance } from 'antd';

/**
 * 计算结果项的通用类型定义
 */
export interface ResultItem {
  key: string;
  name: string;
  value: number | string;
  unit: string;
  category?: string;
}

/**
 * 基础计算结果类型定义
 */
export interface CalculationResult {
  success: boolean;
  results: ResultItem[];
  rawData?: any;
}

/**
 * 基础表单类型定义
 */
export type BaseFormInstance = FormInstance<any>;

/**
 * 用于安全地获取和设置表单值的工具类型
 */
export interface SafeFormHandler {
  getFieldsValue: <T = any>() => T;
  setFieldsValue: (values: any) => void;
  validateFields: () => Promise<any>;
}

/**
 * 类型安全的表单计算函数
 */
export type CalculationFunction<T = any> = (values: T) => Promise<any>;

/**
 * 基础计算参数类型
 */
export interface BaseCalculationParams {
  [key: string]: number | string | undefined;
}

/**
 * IPC响应类型定义
 */
export type IpcResponse = 
  | { success: true; data?: any; error?: undefined; results: any; rawData: any }
  | { success: false; data?: undefined; error?: string; results?: never[] };
